home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
com
/
othernet
/
fidonet
/
raw_nl1
/
getrawnl.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-25
|
3KB
|
116 lines
/*
** Access to RAW-Nodelist using NODELIST.RDX.
**
** Copyright 1995 St.Slabihoud. Freeware.
**
** You may copy and distribute this source, documentation and
** executable code as you receive it. You can use this source
** in your own programs.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ext.h>
#include <time.h>
#include <portab.h>
#include <defines.h>
#define VERSION "0.01"
HEADER header;
NLHEADER *nlheader;
ENTRY entry;
#define F_REGION (1U << 0)
#define F_HOST (1U << 1)
#define F_HUB (1U << 2)
#define F_PVT (1U << 3)
#define F_DOWN (1U << 4)
#define F_HOLD (1U << 5)
#define F_CM (1U << 6)
#define F_MO (1U << 7)
#define M_V32T (1U << 0)
#define M_VFC (1U << 1)
#define M_HST (1U << 2)
#define M_PEP (1U << 3)
#define M_ZYX (1U << 4)
#define M_ISDNA (1U << 5)
#define M_ISDNB (1U << 6)
#define M_ISDNC (1U << 7)
int main(uword argc,ubyte *argv[])
{ uword zone,net,node,point,i;
ubyte tmp[256];
FILE *fp,*fptmp;
--argc;
if (argc!=1)
{ fprintf(stderr,"GETRAWNL V"VERSION" Nodelist-Utility (Demo) (c) Stephan Slabihoud 1995\n\n\n");
fprintf(stderr,"Usage: getrawnl <4d-addr>\n");
getch();
exit(2);
}
printf("GETRAWNL V"VERSION" Nodelist-Utility (Demo) (c) Stephan Slabihoud 1995\n\n\n");
strcpy(tmp,argv[1]);
sscanf(tmp,"%u:%u/%u.%u",&zone,&net,&node,&point);
printf("\nSearching for: %u:%u/%u.%u\n\n",zone,net,node,point);
/*
** Open Index-File
*/
fp=fopen("NODELIST.RDX","rb");
/*
** Read Index-Header
*/
fread(&header,sizeof(HEADER),1,fp);
printf(" Version: %u.%02u\n",header.version >> 8,header.version & 0xff);
printf(" Created: %s\n",ctime(&(time_t)header.datetime));
printf("Nodelists: %u\n",header.nodelists);
printf(" Sorted: %s\n\n",header.flag==0 ? "No" : "Yes (binary access possible)");
/*
** Now read all Nodelist-Header
*/
nlheader = (NLHEADER *)malloc(sizeof(NLHEADER)*header.nodelists);
fread(&nlheader[0],sizeof(NLHEADER),header.nodelists,fp);
printf("Found following nodelists/pointlists:\n");
for (i=0; i<header.nodelists; i++)
{ printf("Day: %03u - %s\n",nlheader[i].day,
*nlheader[i].network=='\0' ?
"unknown" : nlheader[i].network);
}
printf("\n");
/*
** And now search for the address. This could be done using the
** binary-search when all entries are sorted.
*/
while(!feof(fp))
{ fread(&entry,sizeof(ENTRY),1,fp);
if (entry.zone==zone && entry.net==net &&
entry.node==node && entry.point==point)
{ printf("Address found in: %s\n",nlheader[entry.nodelist].file);
printf(" List is a %s\n",nlheader[entry.nodelist].type==0 ? "Nodelist" : "Pointlist");
printf(" Flags: %x, %x\n",entry.f_flags,entry.m_flags);
fptmp=fopen(nlheader[entry.nodelist].file,"rb");
fseek(fptmp,entry.offset,SEEK_SET);
fgets(tmp,256,fptmp);
printf(" Entry: %s\n\n",tmp);
fclose(fptmp);
}
}
free(nlheader);
fclose(fp);
return(0);
}